import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import login from '../views/Login.vue'
import page from './pages'
import refresh from '@/views/refreshIndirect.vue'

const routes = [
  {
    path: '/',
    redirect: '/index/indexabout',
    // redirect: '/login',
  },
  {
    path: '/index',
    name: 'index',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Index.vue'),
    redirect: '/index/indexabout',
    children: [
      {
        path: 'refresh/:path(.*)',//:path(.*)搜索的内容----*(一个或者多个)
        name: 'refresh-chlid',
        component: refresh,
      },
      {
        path: 'indexabout',
        name: 'indexabout',
        component: () => import(/* webpackChunkName: "about" */ '../views/indexabout.vue'),
        meta: {
          title: "首页"
        }
      },
      {
        path: 'myselfinfo',
        name: 'myselfinfo',
        component: () => import('@/views/myself/myselfinfo.vue'),
        meta: {
          title: "个人信息"
        }
      }, {
        path: "mypassword",
        name: "mypassword",
        component: () => import( '@/views/myself/mypassword.vue'),
        meta: {
          title: "修改密码"
        }
      },
      ...page,

    ]
  },
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import(/* webpackChunkName: "about" */ '../views/404.vue')
  },
  {
    path: '/:path(.*)+',
    name: 'gnfd',
    redirect: '/404'
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
